home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
433_01
/
svgadem2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-08
|
31KB
|
1,214 lines
/****************************************************************************
'SVGACC' A Super Vga Graphics Library for use with Microsoft and
Borland C/C++
Copyright 1993-1994 by Stephen L. Balkum and Daniel A. Sill
GIF and 'Graphics Intechange Format' are trademarks (tm) of
Compuserve, Incorporated, an H&R Block Company.
**************** UNREGISTERD SHAREWARE VERSION ***********************
* FOR EVUALATION ONLY. NOT FOR RESALE IN ANY FORM. SOFTWARE WRITTEN *
* USING THIS UNREGISTERED SHAREWARE GRAPHICS LIBRARY MAY NOT BY SOLD *
* OR USED FOR ANY PURPOSE OTHER THAN THE EVUALTION OF THIS LIBRARY. *
**********************************************************************
**************** NO WARRANTIES AND NO LIABILITY **********************
* Stephen L. Balkum and Daniel A. Sill provide no warranties, either *
* expressed or implied, of merchantability, or fitness, for a *
* particular use or purpose of this SOFTWARE and documentation. *
* In no event shall Stephen L. Balkum or Daniel A. Sill be held *
* liable for any damages resulting from the use or misuse of the *
* SOFTWARE and documentation. *
**********************************************************************
************** U.S. GOVERNMENT RESTRICTED RIGHTS *********************
* Use, duplication, or disclosure of the SOFTWARE and documentation *
* by the U.S. Government is subject to the restictions as set forth *
* in subparagraph (c)(1)(ii) of the Rights in Technical Data and *
* Computer Software cluse at DFARS 252.227-7013. *
* Contractor/manufacturer is Stephen L. Balkum and Daniel A. Sill, *
* P.O. Box 7704, Austin, Texas 78713-7704 *
**********************************************************************
**********************************************************************
* By using this SOFTWARE or documentation, you agree to the above *
* terms and conditions. *
**********************************************************************
***************************************************************************/
#define MODULE
#include <stdio.h>
#include <conio.h>
#include <malloc.h>
#include <string.h>
#include <dos.h>
#include <math.h>
#include "svgacc.h"
#include "svgademo.h"
char showgif(char fname[]);
void showhouse(D2Point *plotarray, D2Point *oplotarray);
void showstar(D2Point *plotarray, D2Point *oplotarray);
/********
* DO2D *
********/
char do2d(void)
{
int i, trans;
int spcing, cntx, cnty;
D2Point pointarray[9];
D2Point plotarray[9];
D2Point oplotarray[9];
char ret;
char title[TITLEN];
char buf[TITLEN];
char buf2[TITLEN];
/*
* Set up the Title
*/
sprintf(title,"DEMO 11: 2D functions");
palset(pal,0,255);
/*
* Set up the star patter of points
*/
cntx = maxx / 2;
cnty = (maxy - 32) / 2 + 32;
spcing = maxx / 15;
pointarray[0].x = 0;
pointarray[0].y = -spcing * 3;
pointarray[1].x = spcing;
pointarray[1].y = -spcing;
pointarray[2].x = spcing * 3;
pointarray[2].y = 0;
pointarray[3].x = spcing;
pointarray[3].y = spcing;
pointarray[4].x = 0;
pointarray[4].y = spcing * 3;
pointarray[5].x = -spcing;
pointarray[5].y = spcing;
pointarray[6].x = -spcing * 3;
pointarray[6].y = 0;
pointarray[7].x = -spcing;
pointarray[7].y = -spcing;
pointarray[8].x = 0;
pointarray[8].y = -spcing * 3;
/*
* Show d2translate
*/
fillscreen(0);
setview(0,0,maxx,maxy);
drwstring(1,7,0,title,10,0);
sprintf(buf,"d2translate(point,xtrans,ytrans,inarray,outarray);");
drwstring(1,7,0,buf,10,16);
setview(0,32,maxx,maxy);
d2translate(9,cntx,cnty,pointarray,plotarray);
showstar(plotarray,oplotarray);
ret = getkey();
if ((ret=='s') || (ret=='q')) {
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
trans = 0;
for(i=0;i<spcing;i++) {
trans+=2;
d2translate(9,cntx+trans,cnty+trans,pointarray,plotarray);
showstar(plotarray,oplotarray);
sdelay(2);
}
for(i=0;i<spcing;i++) {
trans-=2;
d2translate(9,cntx+trans,cnty+trans,pointarray,plotarray);
showstar(plotarray,oplotarray);
sdelay(2);
}
ret = getkey();
if ((ret=='s') || (ret=='q')) {
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*
* Show d2scale
*/
setview(0,16,maxx,31);
fillview(0);
setview(0,16,maxx,maxy);
sprintf(buf,"d2scale(points,xscale,yscale,inarray,outarray);");
drwstring(1,7,0,buf,10,16);
setview(0,32,maxx,maxy);
d2translate(9,cntx,cnty,pointarray,plotarray);
showstar(plotarray,oplotarray);
for(i=256;i<=380;i+=4) {
d2scale(9,i,i,pointarray,plotarray);
d2translate(9,cntx,cnty,plotarray,plotarray);
showstar(plotarray,oplotarray);
sdelay(2);
}
for(i=384;i>=128;i-=4) {
d2scale(9,i,i,pointarray,plotarray);
d2translate(9,cntx,cnty,plotarray,plotarray);
showstar(plotarray,oplotarray);
sdelay(2);
}
for(i=124;i<=256;i+=4) {
d2scale(9,i,i,pointarray,plotarray);
d2translate(9,cntx,cnty,plotarray,plotarray);
showstar(plotarray,oplotarray);
sdelay(2);
}
ret = getkey();
if ((ret=='s') || (ret=='q')) {
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*
* Show d2rotate
*/
setview(0,16,maxx,31);
fillview(0);
setview(0,16,maxx,maxy);
sprintf(buf,"d2rotate(points,xorigin,yorigin,angle,inarray,outarray);");
drwstring(1,7,0,buf,10,16);
sprintf(buf2,"Let's do it about the center of the object.");
drwstring(1,7,0,buf2,10,32);
setview(0,48,maxx,maxy);
d2translate(9,cntx,cnty,pointarray,plotarray);
showstar(plotarray,oplotarray);
for(i=0;i<=180;i++) {
d2rotate(9,0,0,i,pointarray,plotarray);
d2translate(9,cntx,cnty,plotarray,plotarray);
showstar(plotarray,oplotarray);
sdelay(2);
}
for(i=180;i>=0;i-=2) {
d2rotate(9,0,0,i,pointarray,plotarray);
d2translate(9,cntx,cnty,plotarray,plotarray);
showstar(plotarray,oplotarray);
sdelay(2);
}
ret = getkey();
if ((ret=='s') || (ret=='q')) {
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*
* Show d2rotate (about an arbitrary point)
*/
setview(0,16,maxx,48);
fillview(0);
setview(0,16,maxx,maxy);
sprintf(buf,"d2rotate(points,xorigin,yorigin,angle,inarray,outarray);");
drwstring(1,7,0,buf,10,16);
sprintf(buf2,"Let's do it about an arbitrary point.");
drwstring(1,7,0,buf2,10,32);
setview(0,48,maxx,maxy);
d2translate(9,cntx,cnty,pointarray,plotarray);
showstar(plotarray,oplotarray);
for(i=0;i<=360;i+=2) {
d2rotate(9,0,spcing*3,i,pointarray,plotarray);
d2translate(9,cntx,cnty,plotarray,plotarray);
showstar(plotarray,oplotarray);
sdelay(2);
}
ret = getkey();
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/********
* DO3D *
********/
char do3d(void)
{
float pi;
int i;
float height, radius;
int spcing;
D3Point pointarray[14];
D3Point playarray[14];
D2Point plotarray[14];
D2Point oplotarray[14];
ProjParameters proj;
char ret;
char title[TITLEN];
char buf[TITLEN];
/*
* Set up the Title
*/
sprintf(title,"DEMO 12: 3D functions");
palset(pal,0,255);
/*
* Set up the house pattern of points
*/
spcing = maxx / 6;
pointarray[0].x = -spcing;
pointarray[0].y = -spcing * 2;
pointarray[0].z = 0;
pointarray[1].x = spcing;
pointarray[1].y = -spcing * 2;
pointarray[1].z = 0;
pointarray[2].x = spcing;
pointarray[2].y = -spcing * 2;
pointarray[2].z = spcing * 2;
pointarray[3].x = -spcing;
pointarray[3].y = -spcing * 2;
pointarray[3].z = spcing * 2;
pointarray[4].x = -spcing;
pointarray[4].y = spcing * 2;
pointarray[4].z = 0;
pointarray[5].x = spcing;
pointarray[5].y = spcing * 2;
pointarray[5].z = 0;
pointarray[6].x = spcing;
pointarray[6].y = spcing * 2;
pointarray[6].z = spcing * 2;
pointarray[7].x = -spcing;
pointarray[7].y = spcing * 2;
pointarray[7].z = spcing * 2;
pointarray[8].x = 0;
pointarray[8].y = -spcing * 2;
pointarray[8].z = sp